<template>
  <transition name="fade">
    <div class="dialog-mask" @click.prevent="dialogClose">
      <div class="dialog-wrapper animated fadeInUp" ref="dialogWrapper">
        <div
          class="dialog-container"
          :style="`height:${dialogHeight}px`"
          @click.stop=""
        >
          <div class="dialog-header">
            <svg-icon icon-class="new_close" @click="dialogClose"></svg-icon>
          </div>
          <div class="dialog-body">
            <slot name="body"></slot>
          </div>
          <div class="dialog-footer">
            <slot name="footer"></slot>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  name: "customDialog",
  props: {
    dialogHeight: {
      default() {
        return 182;
      },
    },
    cancel: {
      default() {
        return "取消";
      },
    },
    confirm: {
      default() {
        return "删除";
      },
    },
  },
  components: {},
  data() {
    return {};
  },
  methods: {
    // 关闭
    dialogClose() {
      this.$emit("dialogClose");
    },
    // 确认
    dialogSubmit() {
      this.$emit("dialogSubmit");
    },
  },
  computed: {},
  watch: {},
};
</script>

<style lang='scss' scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.4s;
}
.fade-enter,
.fade-leave-active {
  opacity: 0;
}
.dialog-mask {
  background-color: rgba(0, 0, 0, 0.5);
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 1001;
  display: table;
  animation-duration: 0.6s;
  .dialog-wrapper {
    display: table-cell;
    vertical-align: middle;
    animation-duration: 0.3s;
    .dialog-container {
      display: flex;
      flex-direction: column;
      margin: auto;
      top: 50%;
      width: 470px;
      background: #ffffff;
      border-radius: 12px;
      padding: 24px;
      padding-bottom: 16px;
      .dialog-header {
        height: 32px;
        display: flex;
        justify-content: right;
        align-items: center;
        font-size: 13px;
        .svg-icon {
          height: 20px;
          width: 20px;
          color: #8c8c8c;
          opacity: 0.45;
          cursor: pointer;
        }
      }
      .dialog-body {
        display: flex;
        justify-content: start;
        align-items: flex-start;
        flex: 1;
        font-size: 13px;
      }
      .dialog-footer {
        height: 40px;
        width: 100%;
        background-color: #ffffff;
        border-radius: 0 0 12px 12px;
        display: flex;
        justify-content: right;
      }
    }
  }
}
</style>